package cn.org.mrliu.ssm.common.web.interceptor;

import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.Arrays;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.core.MethodParameter;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class ParamInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		if (handler instanceof HandlerMethod) {
			System.out.println("ParamInterceptor pre....");
			HandlerMethod handlerMethod = (HandlerMethod) handler;
//			System.out.println(handlerMethod.getBean());
//			System.out.println(handlerMethod.getBeanType().getSimpleName());
//			System.out.println(handlerMethod.getClass());
//			System.out.println(handlerMethod.getMethod());
//			System.out.println(handlerMethod.getMethod().getModifiers());
//			System.out.println(handlerMethod.getMethod().getReturnType());
//			System.out.println(handlerMethod.getMethod().getGenericReturnType());
//			System.out.println(handlerMethod.getMethod().getName());
//			System.out.println(Arrays.toString(handlerMethod.getMethod().getParameterTypes()));
//			System.out.println(Arrays.toString(handlerMethod.getMethod().getParameterTypes()));
//			System.out.println(Arrays.toString(handlerMethod.getMethod().getExceptionTypes()));
//			System.out.println(handlerMethod.getResolvedFromHandlerMethod());
//			System.out.println(Arrays.toString(handlerMethod.getMethodParameters()));
//			System.out.println(handlerMethod.getReturnType());
			MethodParameter[] methodParameters = handlerMethod.getMethodParameters();
			for (MethodParameter methodParameter : methodParameters) {
				System.out.println(methodParameter.getParameterName());
				System.out.println(methodParameter);
			}
		}
		return true;
	}
}
